package com.dilidili.controller;

import com.dilidili.service.IVideoService;
import com.domain.Video;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @PackgeName: com.dilidili.controller
 * @ClassName: VideoController
 * @Author: 零
 * Date: 2022/4/9 10:45
 * project name: spring-cloud-mybilibli
 * @Version:
 * @Description:
 */
@RestController
@RequestMapping("/video")
public class VideoController {

    /**
     * 视频业务接口
     */
    @Autowired
    private IVideoService videoService;

    /**
     * 请求返回用户发布视频总量
     * @param userId 用户对象id
     * @return 响应结果
     */
    @RequestMapping("playCounts")
    public Integer playCounts(Integer userId){
        return videoService.playCounts(userId);
    }

    /**
     * 请求查看用户发布的视频
     * @param userId 用户id
     * @param pageNum 当前第几页
     * @param pageSize  当前页有几条数据
     * @return 响应结果
     */
    @RequestMapping("queryUserId")
    public PageInfo<Map> queryUserId(Integer userId,Integer pageNum, Integer pageSize){
        return videoService.queryUserId(userId,pageNum,pageSize);
    }

    /**
     *
     * @param userId
     * @return
     */
    @RequestMapping("bigzoneByUserCount")
    public List<Map<String, Object>> bigzoneByUserCount(Integer userId) {
        return videoService.bigzoneByUserCount(userId);
    }


    /**
     * 用户请求根据类型查询视频
     * @param userId 用户id
     * @param bigzoneName 类型
     * @param pageNum 分页
     * @param pageSize
     * @return
     */
    @RequestMapping("synthesizeQuery")
    public PageInfo<Map> synthesizeQuery(Integer userId, String bigzoneName, Integer pageNum, Integer pageSize) {
        return videoService.synthesizeQuery(userId,bigzoneName,pageNum,pageSize);
    }

    /**
     * 用户请求查询播放量最多的视频排序
     * @param userId
     * @param bigzoneName
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("synthesizeQueryDesc")
    public PageInfo<Map> synthesizeQueryDesc(Integer userId, String bigzoneName, Integer pageNum, Integer pageSize) {
        return videoService.synthesizeQueryDesc(userId,bigzoneName,pageNum,pageSize);
    }

    /**
     * 用户请求查询收藏的视频
     * @param userId 用户id
     * @param pageNum 分页
     * @param pageSize
     * @return
     */
    @RequestMapping("collectvideoUserById")
    public PageInfo<Map<String, Object>> collectvideoUserById(Integer userId, Integer pageNum, Integer pageSize) {
        return videoService.collectvideoUserById(userId,pageNum,pageSize);
    }

    /**
     * 查询用户总视频播放量
     * @param userId
     * @return /{userId} @PathVariable("userId")
     */
    @RequestMapping(value = "videoIsreprintSum",method = RequestMethod.GET)
    public Integer videoIsreprintSum(Integer userId) {
        return videoService.videoIsreprintSum(userId);
    }

    /**
     * 查询用户被下架的视频
     * @param userId 用户id
     * @param videoTitle 用户标题
     * @param pageNum 分页
     * @param pageSize
     * @return
     */
    @RequestMapping("videoSold")
    public PageInfo<Map<String,Object>> videoSold(Integer userId, String videoTitle, Integer pageNum, Integer pageSize) {
        return videoService.videoSold(userId,videoTitle,pageNum,pageSize);
    }

    /**
     * 删除视频SQL
     * @param videoId
     * @return
     */
    @RequestMapping("videoDelByVideoId")
    public Integer videoDelByVideoId(Integer videoId){
        return videoService.videoDelByVideoId(videoId);
    }
}
